package com.itheima.properties;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

public class PropertiesDemo01 {
    public static void main(String[] args) throws IOException {
        Properties prop = new Properties();
        prop.setProperty("张三","20");
        prop.setProperty("李四","30");
        prop.setProperty("王五","12");
        prop.setProperty("赵六","26");
        prop.setProperty("钱七","28");
        prop.setProperty("甲乙丙丁","18");

        FileWriter fw = new FileWriter("prop.properties");
        prop.store(fw,null);
        fw.close();

        Properties prop1 = new Properties();
        FileReader fr = new FileReader("prop.properties");
        prop1.load(fr);

        Set<Map.Entry<Object, Object>> entries = prop1.entrySet();
        for (Map.Entry<Object, Object> entry : entries) {
            System.out.println(entry.getKey()+" = " +entry.getValue());
        }
    }
}
